Questions
40 of 50
1What is a pseudo-class in CSS?
2How are pseudo-classes different from pseudo-elements?
3What is the syntax of a pseudo-class in CSS?
4Give some commonly used pseudo-classes.
5What does the :hover pseudo-class do?
6What’s the purpose of the :active pseudo-class?
7How does the :visited pseudo-class work for links?
8What is the :focus pseudo-class used for?
9What does the :checked pseudo-class do?
10How does the :disabled pseudo-class behave?
11What is the difference between :first-child and :first-of-type?
12How do :nth-child() and :nth-of-type() differ?
13How do you select every odd or even element using pseudo-classes?
14How can you style an element when it’s being hovered over along with its child?
15What does the :not() pseudo-class do?
16How can you use multiple pseudo-classes together?
17What is the difference between :link and :visited?
18What does the :target pseudo-class represent?
19How can you use :empty to detect empty elements?
20How does the :root pseudo-class differ from the html selector?
21What does the :valid and :invalid pseudo-class do?
22How can you use :required and :optional pseudo-classes in forms?
23What is the use of :in-range and :out-of-range?
24What does :read-only and :read-write do?
25How can you style an input field when it’s autofilled?
26How does the :focus-within pseudo-class work?
27What’s the difference between :focus and :focus-visible?
28What is the purpose of the :placeholder-shown pseudo-class?
29How can you style a checkbox when it is checked or unchecked?
30How can you style invalid form inputs without JavaScript?
31Can pseudo-classes be chained together? Give an example.
32What is the specificity of pseudo-classes compared to normal selectors?
33How can you use :not() effectively to exclude elements from styling?
34How does :has() pseudo-class work, and why is it powerful?
35Is :has() supported in all browsers?
36How does :is() differ from :where() in terms of specificity?
37How can you combine :is() or :where() with other selectors for cleaner code?
38What’s the difference between :nth-child() and :nth-last-child()?
39How can you style only the last element of a list using pseudo-classes?
40What does the :lang() pseudo-class do?
41How do you change a button’s color when hovered but not when disabled?
42How can you highlight the current section in a menu using :target?
43How can you style a form field differently when focused and valid?
44How do you style every third list item differently?
45How can you style alternate table rows without adding extra classes?
46How do you hide empty <p> tags using pseudo-classes?
47How can you style the parent when any child inside it is focused?
48How can you highlight a link only when it’s both focused and hovered?
49How can you style the first letter of only the first paragraph using pseudo-classes?
50How would you use :has() to select a <div> that contains an image?
40 / 50

What does the :lang() pseudo-class do?

Using the :lang() Pseudo-Class in CSS

The :lang() pseudo-class in CSS allows you to target elements based on their language attribute (lang). This is useful for applying language-specific styling, such as font, text direction, or typographic rules.

Key Points About :lang()
  1. 1

    :lang(language-code) – Selects elements whose language matches the specified code, e.g., :lang(en) for English or :lang(fr) for French.

  2. 2

    Matches both the lang attribute on the element and inherited language from parent elements.

  3. 3

    Useful for internationalization, styling multilingual content differently.

Example: Styling Based on Language

In this example, the English paragraph uses Arial and navy text, while the French paragraph uses Times New Roman and dark red text, demonstrating language-specific styling with :lang().

Best Practices
  1. 1

    Use :lang() for multilingual websites to enhance readability and cultural appropriateness.

  2. 2

    Combine with other pseudo-classes like :first-letter or :first-line for detailed typographic styling.

  3. 3

    Ensure correct lang attributes are set on elements to make this pseudo-class effective.

  4. 4

    Test across browsers as support is broad but always verify inherited language behavior.

Difficulty: 3/10
Topics: language targeting, CSS pseudo-classes, internationalization

Scenario Questions

0-2 years experience
  1. 1

    You're building a bilingual blog where French paragraphs need italic styling — how would you use :lang() to target them correctly?

  2. 2

    A user reports that Spanish text isn't showing the right font — you see the HTML has lang='es', but your CSS uses :lang(spanish). What's wrong?

  3. 3

    How would you write a CSS rule to apply a different quotation style only to German text inside a div with lang='de'?

2-5 years experience
  1. 1

    Our multilingual app has dynamic content loaded via API — sometimes the lang attribute is missing or inconsistent. How would you debug why :lang() styles aren't applying in production?

  2. 2

    We're using :lang() to adjust punctuation spacing for Japanese vs English, but users on iOS Safari report inconsistent rendering. What could be causing this, and how would you fix it?

  3. 3

    A designer wants to use :lang() to change font weights for Arabic text, but the site also uses a CMS that sometimes outputs lang='ar-SA' and other times lang='ar'. How would you handle this ambiguity?

5-8 years experience
  1. 1

    We're redesigning our global content platform and need to support over 20 languages with custom typography. How would you architect the CSS strategy using :lang() without creating a maintenance nightmare?

  2. 2

    A performance audit shows our CSS bundle is bloated because we're using dozens of :lang() rules. What alternatives or optimizations would you consider, and what tradeoffs do they introduce?

  3. 3

    We're migrating from a legacy system that used class-based language targeting to :lang(). What edge cases in content rendering or CMS output might break during this transition?

8+ years experience
  1. 1

    Our company supports 50+ languages across 10 products — how would you standardize language-based styling across teams without creating CSS fragmentation or accessibility gaps?

  2. 2

    We're considering deprecating class-based language styling in favor of :lang(), but legacy content has inconsistent lang attributes. How would you design a migration plan that minimizes UX impact and ensures compliance?

  3. 3

    How would you advocate for :lang() as a core accessibility and internationalization primitive in our design system, and what metrics would you track to prove its impact across regions?

Follow-up Questions

  • What happens if the HTML lang attribute is missing or misspelled?
  • Can :lang() match nested elements with different languages?
  • How would you debug a :lang() rule that isn't applying?